//
//  Tool.m
//  UILesson12_UITableViewCellHeight
//
//  Created by lanou3g on 16/3/2.
//  Copyright © 2016年 李曼. All rights reserved.
//

#import "Tool.h"

@implementation Tool

//创建类方法根据文本计算label的高度
+ (CGFloat)labelHeightWithText:(NSString *)text font:(UIFont *)font{
    CGSize size = CGSizeMake([UIScreen mainScreen].bounds.size.width,10000);
    
    NSDictionary *dic =@{NSFontAttributeName:font};
    
    CGRect rect = [text boundingRectWithSize:size options: NSStringDrawingUsesLineFragmentOrigin  attributes:dic context:nil];
    
    return rect.size.height;
}

//创建类方法根据image计算imageView的高度
+ (CGFloat)imageScaleHeightWith:(NSString *)imageName{
    
    UIImage *image = [UIImage imageNamed:imageName];
    CGFloat width = image.size.width;
    CGFloat height = image.size.height;
    return height / width * [UIScreen mainScreen].bounds.size.width;
}

@end
